now real time monitoring of DAMASK_spectral output to screen

working with GNU Fortran as well (new checking for return code)
This commit is contained in:
Martin Diehl 2012-06-25 09:03:19 +00:00
parent 9d6cb691be
commit 767842acbf
1 changed files with 9 additions and 10 deletions

View File

@ -46,22 +46,21 @@ start = 1
exitCode=2 exitCode=2
print 'load case', options.loadcase print 'load case', options.loadcase
print 'geometry', options.geometry print 'geometry', options.geometry
f=open('monitor','w') res=numpy.array([24,24,24])
#res=numpy.array([6,6,6])
res=numpy.array([0,0,0])
while exitCode == 2: while exitCode == 2:
print 'restart at ', start print 'restart at ', start
out=subprocess.Popen(['DAMASK_spectral', '-l', '%s'%options.loadcase, '-g', '%s'%options.geometry, '--regrid', '%i'%start],stderr=subprocess.PIPE,stdout=f) proc=subprocess.Popen(executable='DAMASK_spectral',\
#out=subprocess.Popen(['DAMASK_spectral', '-l', '%s'%options.loadcase, '-g', '%s'%options.geometry, '-r', '%i'%start],stderr=subprocess.PIPE,stdout=f) args=['-l', '%s'%options.loadcase, '-g', '%s'%options.geometry, '--regrid', '%i'%start],\
stderr = out.communicate() stderr=subprocess.PIPE,stdout=subprocess.PIPE, bufsize=1)
stderrLines = string.split(stderr[1],'\n') while proc.poll() is None: # while process is running
exitCode = int(stderrLines[-2]) myLine = proc.stdout.readline()
print 'exit code', exitCode if len(myLine)>1: print myLine[0:-1] # print output without extra newline
exitCode = proc.returncode
if exitCode==2: if exitCode==2:
os.system('rm -rf %i'%start) os.system('rm -rf %i'%start)
os.system('mkdir %i'%start) os.system('mkdir %i'%start)
os.system('cp * %i/.'%start) os.system('cp * %i/.'%start)
start = int(string.split(re.search('restart at\s+\d+',stderr[1]).group(0))[2]) start = int(string.split(re.search('restart at\s+\d+',proc.stderr.readlines()[-2]).group(0))[2]) #restart step is in second last line in stderr, search for restart at xxx
#------------regridding---------------------------------------------- #------------regridding----------------------------------------------
#-------------------------------------------------------------------- #--------------------------------------------------------------------
damask.core.prec.prec_init() damask.core.prec.prec_init()