diff --git a/lib/damask/config/material.py b/lib/damask/config/material.py index f59720fc5..b887856b3 100644 --- a/lib/damask/config/material.py +++ b/lib/damask/config/material.py @@ -118,7 +118,7 @@ class Material(): def __repr__(self): me = [] for part in self.parts: - print 'doing',part + print('doing',part) me += ['','#-----------------------------#','<%s>'%part,'#-----------------------------#',] for section in self.data[part]['__order__']: me += ['','[%s] %s'%(section,'-'*max(0,27-len(section))),'',] @@ -260,7 +260,7 @@ def ex1(): mat.add_section('phase','phase1',p) mat.add_section('texture','tex1',t) mat.add_microstructure('mustruct1',{'phase':['phase1']*2,'texture':['tex1']*2,'fraction':[0.2]*2}) - print mat + print(mat) mat.write(file='poop') mat.write(file='poop',overwrite=True) \ No newline at end of file diff --git a/lib/damask/config/material_2012-09-07.py b/lib/damask/config/material_2012-09-07.py index 16cc52d9a..dca5e1c80 100644 --- a/lib/damask/config/material_2012-09-07.py +++ b/lib/damask/config/material_2012-09-07.py @@ -27,7 +27,7 @@ class Material(): def __repr__(self): me = [] for part in self.parts: - print 'doing',part + print('doing',part) me += ['','#-----------------------------#','<%s>'%part,'#-----------------------------#',] for section in self.data[part]['__order__']: section_number=self.data[part]['__order__'].index(section) @@ -185,7 +185,7 @@ class Microstructure(Section): theData = '' for property in ['phase','texture','fraction']: if property not in data.keys(): # suboptimal!! - print 'Croak!' + print('Croak!') else: theData += '%s %s\t'%(property,data[property]) self.add_multiKey('constituent',theData) @@ -265,7 +265,7 @@ def example_1(write_file=False): p.add_key('interaction_slipslip',[1]*27) mat.add_section('phase','phase_label',p) - print mat + print(mat) mat.write(file='material.config_example_1') mat.write(file='material.config_example_1',overwrite=True) return mat diff --git a/lib/damask/result/marc2vtk.py b/lib/damask/result/marc2vtk.py index 372827e21..01f6b3645 100644 --- a/lib/damask/result/marc2vtk.py +++ b/lib/damask/result/marc2vtk.py @@ -23,31 +23,31 @@ class MARC_POST(): def opent16(self,incr=None): self.fpath=os.path.join(self.projdir,self.postname) - print 'Trying to open ',self.fpath,' ...' + print('Trying to open ',self.fpath,' ...') self.p=py_post.post_open(self.fpath) if self.p==None: - print 'Could not open %s.'%self.postname; #return 'err'#; sys.exit(1) + print('Could not open %s.'%self.postname); #return 'err'#; sys.exit(1) raise Exception('Could not open t16') - print 'Postfile %s%s is open ...'%(self.projdir,self.postname) + print('Postfile %s%s is open ...'%(self.projdir,self.postname)) self.maxincr=self.p.increments() - print 'and has %i increments'%self.maxincr + print('and has %i increments'%self.maxincr) if incr is None: self.p.moveto(self.maxincr-1) else: self.p.moveto(incr+1) - print 'moved to increment ', self.p.increment + print('moved to increment ', self.p.increment) self.p.extrapolation('translate') # linear, translate, average. query with p.extrapolate - print 'extrapolation method is ', self.p.extrapolate - print 'collecting model information' + print('extrapolation method is ', self.p.extrapolate) + print('collecting model information') self.t16info(printFlag=0) - print 't16 is open' + print('t16 is open') self.p def t16info(self, printFlag=1 ): if not self.p: self.p=self.opent16()#post_open(self.postname) - print self.p + print(self.p) oldincr=self.p.position if oldincr==0: self.p.moveto(1) @@ -65,15 +65,15 @@ class MARC_POST(): self.nscal_list[i]=self.p.node_scalar_label(i) for i in range (0,self.elscals): self.elscal_list[i]=self.p.element_scalar_label(i) - if printFlag==1: print i, self.elscal_list[i] + if printFlag==1: print(i, self.elscal_list[i]) for i in range (0,self.eltens): self.elten_list[i]=self.p.element_tensor_label(i) - if printFlag==1: print i, self.elten_list[i] + if printFlag==1: print(i, self.elten_list[i]) for i in range(0,self.p.element_tensors()): - if printFlag==1: print 'Element Tensor: ', i, self.p.element_tensor_label(i) - if printFlag==1: print '' + if printFlag==1: print('Element Tensor: ', i, self.p.element_tensor_label(i)) + if printFlag==1: print('') for i in range(0,self.p.element_scalars()): - if printFlag==1: print 'Element Scalar: ', i, self.p.element_scalar_label(i) + if printFlag==1: print('Element Scalar: ', i, self.p.element_scalar_label(i)) if oldincr==0: self.p.moveto(0) @@ -87,7 +87,7 @@ class MARC_POST(): else: print('post object not open?') except: - print 'ERROR. Could not close FEM result file.' + print('ERROR. Could not close FEM result file.') def getLabelNr(self, label=None, type='Scalar'): if type[0]=='S' or type[0]=='s': # element scalar @@ -506,7 +506,7 @@ class VTK_WRITER(): posXYZ+wVec, posXYZ+wVec+lVec] pts.extend([pts[0]+hVec,pts[1]+hVec,pts[2]+hVec,pts[3]+hVec]) - print len(pts), pts + print(len(pts), pts) self.fsb.write('POINTS %i float\n'%len(pts)) for npts in range(0,len(pts)): self.fsb.write('%f %f %f\n'%(pts[npts][0], pts[npts][1], pts[npts][2])) @@ -543,7 +543,7 @@ class VTK_WRITER(): self.fsb.write('\n') self.fsb.close() - print self.fsb + print(self.fsb) def example_unstructured(self): self.openFile(filename='example_unstructured_grid.vtk') diff --git a/lib/damask/solver/marc.py b/lib/damask/solver/marc.py index ffd74c161..29b945398 100644 --- a/lib/damask/solver/marc.py +++ b/lib/damask/solver/marc.py @@ -104,7 +104,7 @@ class Marc(Solver): if compile: cmd += ' -u ' + user+'.f90' + ' -save y' else: cmd += ' -prog ' + user - print 'job submission with%s compilation: %s'%({False:'out',True:''}[compile],user) + print('job submission with%s compilation: %s'%({False:'out',True:''}[compile],user)) if logfile: log = open(logfile, 'w') print(cmd) @@ -120,7 +120,7 @@ class Marc(Solver): fid_out = open(outFile,'r') for ln in fid_out: if (string.find(ln,'tress iteration') is not -1): - print ln + print(ln) elif (string.find(ln,'Exit number') is not -1): substr = ln[string.find(ln,'Exit number'):len(ln)] exitnumber = int(substr[12:16]) diff --git a/lib/damask/test/test.py b/lib/damask/test/test.py index f6bb9d97f..4fc4c58a6 100644 --- a/lib/damask/test/test.py +++ b/lib/damask/test/test.py @@ -16,10 +16,10 @@ class Test(): def __init__(self,test_description): - print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n' \ + print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n' \ +'----------------------------------------------------------------\n' \ +'| '+test_description+'\n' \ - +'----------------------------------------------------------------' + +'----------------------------------------------------------------') self.dirBase = os.path.dirname(os.path.realpath(inspect.getfile(self.__class__))) self.parser = OptionParser( description = 'Using: $Id run_test.py 1285 2012-02-09 08:54:09Z MPIE\m.diehl $', @@ -37,7 +37,7 @@ class Test(): Run all variants and report first failure. ''' if not self.testPossible(): return -1 - if len(update) == 0 and self.options.update: print ' This test has no reference to update' + if len(update) == 0 and self.options.update: print(' This test has no reference to update') if len(variants) == 0: variants = xrange(len(self.variants)) # iterate over all variants self.clean() self.prepareAll() @@ -50,8 +50,8 @@ class Test(): self.update(variant) elif not self.compare(variant): return variant+1 - except Exception,e : - print '\nWARNING:\n %s\n'%e + except Exception as e : + print('\nWARNING:\n %s\n'%e) return variant+1 return 0 @@ -159,7 +159,7 @@ class Test(): try: shutil.copy2(self.fileInReference(file),self.fileInCurrent(targetfiles[i])) except: - print 'Reference2Current: Unable to copy file ', file + print('Reference2Current: Unable to copy file ', file) def copy_Base2Current(self,sourceDir,sourcefiles=[],targetfiles=[]): @@ -169,8 +169,8 @@ class Test(): try: shutil.copy2(os.path.join(source,file),self.fileInCurrent(targetfiles[i])) except: - print os.path.join(source,file) - print 'Base2Current: Unable to copy file ', file + print(os.path.join(source,file)) + print('Base2Current: Unable to copy file ', file) def copy_Current2Reference(self,sourcefiles=[],targetfiles=[]): @@ -179,7 +179,7 @@ class Test(): try: shutil.copy2(self.fileInCurrent(file),self.fileInReference(targetfiles[i])) except: - print 'Current2Reference: Unable to copy file ', file + print('Current2Reference: Unable to copy file ', file) def copy_Proof2Current(self,sourcefiles=[],targetfiles=[]): @@ -188,7 +188,7 @@ class Test(): try: shutil.copy2(self.fileInProof(file),self.fileInCurrent(targetfiles[i])) except: - print 'Proof2Current: Unable to copy file ', file + print('Proof2Current: Unable to copy file ', file) def copy_Current2Current(self,sourcefiles=[],targetfiles=[]): @@ -196,13 +196,13 @@ class Test(): try: shutil.copy2(self.fileInReference(file),self.fileInCurrent(targetfiles[i])) except: - print 'Current2Current: Unable to copy file ', file + print('Current2Current: Unable to copy file ', file) def execute_inCurrentDir(self,cmd,outfile='execute_log.txt'): os.chdir(self.dirCurrent()) file=open(outfile,'a+') - print cmd + print(cmd) process = subprocess.Popen(shlex.split(cmd),stdout = file,stderr = subprocess.STDOUT) process.wait() file.close() @@ -210,7 +210,7 @@ class Test(): def compare_Array(self,File1,File2): import numpy - print 'comparing\n ' , File1,'\n ', File2 + print('comparing\n ' , File1,'\n ', File2) refFile = open(File1) table = damask.ASCIItable(refFile) table.head_read() @@ -224,7 +224,7 @@ class Test(): max_loc=numpy.argmax(abs(refArrayNonZero[curArray.nonzero()]/curArray[curArray.nonzero()]-1.)) refArrayNonZero = refArrayNonZero[curArray.nonzero()] curArray = curArray[curArray.nonzero()] - print ' ********\n * maximum relative error ',max_err,' for ', refArrayNonZero[max_loc],' and ',curArray[max_loc],'\n ********' + print(' ********\n * maximum relative error ',max_err,' for ', refArrayNonZero[max_loc],' and ',curArray[max_loc],'\n ********') return max_err else: raise Exception('mismatch in array size to compare') @@ -246,7 +246,7 @@ class Test(): absoluteTolerance=False,perLine=False,skipLines=[]): import numpy - print 'comparing ASCII Tables\n' , file0,'\n', file1 + print('comparing ASCII Tables\n' , file0,'\n', file1) if normHeadings == '': normHeadings = headings0 if len(headings0) == len(headings1) == len(normHeadings): #check if comparison is possible and determine lenght of columns @@ -320,9 +320,9 @@ class Test(): norm[i] = [1.0 for j in xrange(line0-len(skipLines))] absTol[i] = True if perLine: - print 'At least one norm of',headings0[i]['label'],'in 1. table is 0.0, using absolute tolerance' + print('At least one norm of',headings0[i]['label'],'in 1. table is 0.0, using absolute tolerance') else: - print 'Maximum norm of',headings0[i]['label'],'in 1. table is 0.0, using absolute tolerance' + print('Maximum norm of',headings0[i]['label'],'in 1. table is 0.0, using absolute tolerance') line1 = 0 while table1.data_read(): # read next data line of ASCII table @@ -335,13 +335,13 @@ class Test(): if (line0 != line1): raise Exception('found ', line0, ' lines in 1. table and ', line1, ' in 2. table') - print ' ********' + print(' ********') for i in xrange(dataLength): if absTol[i]: - print ' * maximum absolute error ',maxError[i],' for ', headings0[i]['label'],' and ',headings1[i]['label'] + print(' * maximum absolute error ',maxError[i],' for ', headings0[i]['label'],' and ',headings1[i]['label']) else: - print ' * maximum relative error ',maxError[i],' for ', headings0[i]['label'],' and ',headings1[i]['label'] - print ' ********' + print(' * maximum relative error ',maxError[i],' for ', headings0[i]['label'],' and ',headings1[i]['label']) + print(' ********') return maxError def compare_TableRefCur(self,headingsRef,ref,headingsCur='',cur='',normHeadings='',normType=None,\ @@ -366,14 +366,14 @@ class Test(): def report_Success(self,culprit): if culprit == 0: - print '%s passed.'%({False: 'The test', - True: 'All %i tests'%(len(self.variants))}[len(self.variants) > 1]) - print '\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' + print('%s passed.'%({False: 'The test', + True: 'All %i tests'%(len(self.variants))}[len(self.variants) > 1])) + print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n') return 0 if culprit == -1: - print 'Warning: Could not start test' + print('Warning: Could not start test') return 0 else: - print ' ********\n * Test %i failed...\n ********'%(culprit) - print '\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' + print(' ********\n * Test %i failed...\n ********'%(culprit)) + print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n') return culprit