2009-03-23 21:38:17 +05:30
|
|
|
#!/usr/bin/env python
|
2009-08-31 20:39:15 +05:30
|
|
|
# $Id$
|
2010-02-10 22:10:50 +05:30
|
|
|
# Writes version specific files for different MARC releases
|
2011-12-15 14:22:41 +05:30
|
|
|
import os,sys,string,damask
|
2009-03-23 21:38:17 +05:30
|
|
|
|
|
|
|
architectures = {
|
|
|
|
'marc': {
|
2011-05-11 22:10:51 +05:30
|
|
|
'parent': 'DAMASK_marc.f90',
|
2010-04-28 12:58:12 +05:30
|
|
|
'versions' : ['%%MARCVERSION%%','2007r1','2008r1','2010'],
|
2009-03-23 21:38:17 +05:30
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2011-12-07 00:08:03 +05:30
|
|
|
bin_link = { \
|
|
|
|
'' : [
|
|
|
|
'DAMASK_spectral.exe',
|
|
|
|
],
|
|
|
|
}
|
2011-12-09 20:43:27 +05:30
|
|
|
|
2011-12-15 14:22:41 +05:30
|
|
|
damaskEnv = damask.Environment('../../') # script location relative to root
|
|
|
|
baseDir = damaskEnv.relPath('code/')
|
2011-03-11 14:50:37 +05:30
|
|
|
|
2009-03-23 21:38:17 +05:30
|
|
|
for arch in architectures:
|
2009-08-26 12:58:43 +05:30
|
|
|
me = architectures[arch]
|
2009-03-23 21:38:17 +05:30
|
|
|
try:
|
2011-12-09 20:43:27 +05:30
|
|
|
parentFile = open(baseDir+os.sep+me['parent'])
|
2009-03-23 21:38:17 +05:30
|
|
|
parentContent = parentFile.readlines()
|
|
|
|
parentFile.close()
|
|
|
|
except IOError:
|
2009-08-26 12:58:43 +05:30
|
|
|
print 'unable to open',me['parent']
|
2009-03-23 21:38:17 +05:30
|
|
|
continue
|
|
|
|
|
2009-08-26 12:58:43 +05:30
|
|
|
|
|
|
|
for version in me['versions'][1:]:
|
2011-12-09 20:43:27 +05:30
|
|
|
childFile = open(baseDir+os.sep+version.join(os.path.splitext(me['parent'])),'w')
|
2009-03-23 21:38:17 +05:30
|
|
|
for line in parentContent:
|
2009-08-26 12:58:43 +05:30
|
|
|
childFile.write(line.replace(me['versions'][0],version))
|
2009-03-23 21:38:17 +05:30
|
|
|
childFile.close()
|
2011-05-11 22:15:37 +05:30
|
|
|
|
2011-12-06 22:28:17 +05:30
|
|
|
# changing dirs in make file
|
2011-12-09 20:43:27 +05:30
|
|
|
|
|
|
|
makefile = open(os.path.join(baseDir,'makefile'))
|
2011-12-06 22:28:17 +05:30
|
|
|
content = makefile.readlines()
|
|
|
|
makefile.close()
|
2011-12-09 20:43:27 +05:30
|
|
|
makefile = open(os.path.join(baseDir,'makefile'),'w')
|
2011-12-06 22:28:17 +05:30
|
|
|
for line in content:
|
|
|
|
if line.startswith('FFTWPATH'):
|
2011-12-15 14:22:41 +05:30
|
|
|
line='FFTWPATH =%s\n'%(damaskEnv.pathInfo['fftw'])
|
2011-12-06 22:28:17 +05:30
|
|
|
print line
|
|
|
|
if line.startswith('ACMLROOT'):
|
2011-12-15 14:22:41 +05:30
|
|
|
line='ACMLROOT =%s\n'%(damaskEnv.pathInfo['acml'])
|
2011-12-06 22:28:17 +05:30
|
|
|
print line
|
|
|
|
makefile.writelines(line)
|
|
|
|
makefile.close()
|
|
|
|
|
|
|
|
# compiling spectral code
|
2011-12-09 20:43:27 +05:30
|
|
|
compile = raw_input("Do you want to compile the spectral code now? (y/n) ")
|
|
|
|
if (compile == 'y' or compile == 'Y'):
|
2011-12-06 22:28:17 +05:30
|
|
|
compiler_switches = raw_input("Please give compiling switches (Enter to use default) ")
|
2011-12-09 20:43:27 +05:30
|
|
|
os.system('make --directory %s clean'%(baseDir))
|
|
|
|
os.system('make --directory %s %s'%(baseDir,compiler_switches))
|
2011-06-14 20:26:10 +05:30
|
|
|
|
2011-06-15 22:10:34 +05:30
|
|
|
if '--clean' in [s.lower() for s in sys.argv]:
|
2011-12-09 20:43:27 +05:30
|
|
|
os.system('make --directory %s clean'%baseDir)
|
2011-12-07 00:08:03 +05:30
|
|
|
|
|
|
|
|
|
|
|
for dir in bin_link:
|
|
|
|
for file in bin_link[dir]:
|
|
|
|
src = os.path.abspath(os.path.join(baseDir,dir,file))
|
|
|
|
if (file == ''):
|
2011-12-15 14:22:41 +05:30
|
|
|
sym_link = os.path.abspath(os.path.join(damaskEnv.binDir(),dir))
|
2011-12-07 00:08:03 +05:30
|
|
|
else:
|
2011-12-15 14:22:41 +05:30
|
|
|
sym_link = os.path.abspath(os.path.join(damaskEnv.binDir(),os.path.splitext(file)[0]))
|
2011-12-07 00:08:03 +05:30
|
|
|
print sym_link,'-->',src
|
|
|
|
if os.path.lexists(sym_link):
|
|
|
|
os.remove(sym_link)
|
|
|
|
os.symlink(src,sym_link)
|