1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from spack import *
class Ffb(MakefilePackage):
"""Computational Fluid Dynamics Software for aeroacoustics"""
homepage = "http://www.ciss.iis.u-tokyo.ac.jp/dl/index.php"
url = "file://{0}/FrontFlow_blue.8.1.tar.gz".format(os.getcwd())
version('8.1', sha256='1ad008c909152b6c27668bafbad820da3e6ec3309c7e858ddb785f0a3d6e43ae')
patch('revocap_refiner.patch')
depends_on('mpi')
depends_on('blas')
depends_on('scalapack')
parallel = False
def flag_handler(self, name, flags):
opt_flag_found = any(f in self.compiler.opt_flags for f in flags)
if name == 'cflags':
if not opt_flag_found:
flags.append('-O3')
elif name == 'cxxflags':
if not opt_flag_found:
flags.append('-O2')
flags.append(self.compiler.cxx_pic_flag)
if name == 'fflags':
if not opt_flag_found:
flags.append('-O3')
flags.append('-mcmodel=large')
if name in ('cflags', 'cxxflags', 'fflags'):
return (None, flags, None)
else:
return (flags, None, flags)
def edit(self, spec, prefix):
workdir = os.getcwd()
cflags = env['CFLAGS']
cxxflags = env['CXXFLAGS']
fflags = env['FFLAGS']
make = join_path('make', 'makefile')
m = FileFilter(make)
m.filter(
r'#LES3DHOME =', 'LES3DHOME= {0}\n'.format(workdir))
make = join_path('make', 'OPTION')
m = FileFilter(make)
m.filter(r'CCOM\s*=.*$', 'CCOM = {0}'.format(spack_cc))
m.filter(r'COPT\s*=.*$', 'COPT = {0}'.format(cflags))
m.filter(r'FCOM\s*=.*$', 'FCOM = {0}\n'.format(spack_fc))
m.filter(r'FOPT\s*=.*$', 'FOPT = {0}\n'.format(fflags))
m.filter(r'INCDIR\s*=.*$', 'INCDIR = {0}\n'
.format(spec['mpi'].headers.directories[0]))
m.filter(r'LIBDIR\s*=.*$', 'LIBDIR = {0}\n'
.format(spec['mpi'].libs.directories[0]))
srcdir = join_path('lib', 'src')
utildir = join_path(workdir, 'util')
with open(join_path('make', 'Makeall'), 'w') as m:
m.write('#!/bin/csh -f\n')
m.write('setenv LES3DHOME {0}\n'.format(workdir))
m.write('cd {0}\n'.format(srcdir))
m.write('./Makeall\n')
m.write('cd {0}\n'.format(utildir))
m.write('./Makeall\n')
makeall = join_path('lib', 'src', 'dd_mpi', 'Makeall')
dd_mpi_dir = join_path('lib', 'src', 'dd_mpi')
with open(makeall, 'w') as m:
m.write('#!/bin/csh -f\n')
m.write('setenv LES3DHOME {0}\n'.format(workdir))
m.write('cd {0}\n'.format(dd_mpi_dir))
m.write('make lib\n')
os.chmod(makeall, 0o755)
makeall = join_path('.', 'Makeall.les')
les3d_dir = join_path('util', 'les3d.mpi')
les3c_dir = join_path('util', 'les3c.mpi')
les3ct_dir = join_path('util', 'les3ct.mpi')
les3x_dir = join_path('util', 'les3x.mpi')
with open(makeall, 'w') as m:
m.write('#!/bin/csh -f\n')
m.write('setenv LES3DHOME {0}\n'.format(workdir))
m.write('cd {0}\n'.format(join_path(workdir, les3d_dir)))
m.write('make CCOM={0}'.format(spec['mpi'].mpicc))
m.write(' FCOM={0}\n'.format(spec['mpi'].mpifc))
m.write('cd {0}\n'.format(join_path(workdir, les3c_dir)))
m.write('make CCOM={0}'.format(spec['mpi'].mpicc))
m.write(' FCOM={0}\n'.format(spec['mpi'].mpifc))
m.write('cd {0}\n'.format(join_path(workdir, les3ct_dir)))
m.write('make CCOM={0}'.format(spec['mpi'].mpicc))
m.write(' FCOM={0}\n'.format(spec['mpi'].mpifc))
m.write('cd {0}\n'.format(join_path(workdir, les3x_dir)))
m.write('make CCOM={0}'.format(spec['mpi'].mpicc))
m.write(' FCOM={0}\n'.format(spec['mpi'].mpifc))
for d in [les3c_dir, les3ct_dir, les3d_dir]:
editfile = join_path(d, 'FILES')
m = FileFilter(editfile)
m.filter(r'-lmpi_f77', '')
os.chmod(makeall, 0o755)
editfile = join_path('lib', 'src', 'Makeall')
m = FileFilter(editfile)
m.filter(r'x86_64-linux', '{0}-linux'.format(spec.target.family))
editfile = join_path('lib', 'src', 'REVOCAP_Refiner-0.4.3', 'OPTIONS')
m = FileFilter(editfile)
m.filter(r'ARCH\s*=.*$', 'ARCH= $(shell arch)-linux')
m.filter(r'CC\s*=.*$', 'CC={0}'.format(spack_cc))
m.filter(r'CFLAGS\s*=.*$', 'CFLAGS={0}'.format(cflags))
m.filter(r'CXX\s*=.*$', 'CXX={0}'.format(spack_cxx))
m.filter(r'CXXFLAGS\s*=.*$',
'CXXFLAGS={0}'.format(cxxflags))
m.filter(r'F90\s*=.*$', 'CC={0}'.format(spack_fc))
m.filter(r'LD\s*=.*$', 'LD={0}'.format(spack_fc))
m.filter(r'LIBPATH\s*=.*$', 'LIBPATH= ')
m.filter(r'FFLAGS\s*=.*$', 'FFLAGS={0}'.format(fflags))
m.filter(r'LDFLAGS\s*=.*$', 'LDFLAGS={0}'.format(fflags))
editfile = join_path('lib', 'src', 'ParMetis-3.1', 'Makefile.in')
m = FileFilter(editfile)
m.filter(r'CC \s*=.*$', 'CC ={0}'.format(spack_cc))
m.filter(r'INCDIR\s*=.*$', 'INCDIR = \n')
editfile = join_path('util', 'xvx2gf', 'Makefile')
m = FileFilter(editfile)
m.filter(
r'#LES3DHOME =', 'LES3DHOME= {0}\n'.format(workdir))
m.filter(r'g\+\+', (spack_cxx))
editfile = join_path('util', 'les3x.mpi', 'FILES')
m = FileFilter(editfile)
m.filter(r'LIBS = -lfort -lgf2 -ldd_mpi -lmpi_f77',
'LIBS = -lfort -lgf2 -ldd_mpi')
def build(self, spec, prefix):
for m in [join_path('make', 'Makeall'),
join_path('lib', 'src', 'dd_mpi', 'Makeall'),
join_path('.', 'Makeall.les')]:
Executable(m)()
def install(self, spec, prefix):
install_tree('bin', prefix.bin)
install_tree('macro', prefix.macro)
def setup_run_environment(self, env):
env.prepend_path('PATH', prefix.macro)
|