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
|
##############################################################################
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/spack/spack
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *
import numbers
def is_integral(x):
"""Any integer value"""
try:
return isinstance(int(x), numbers.Integral) and \
not isinstance(x, bool) and int(x) > 0
except ValueError:
return False
class Nek5000(Package):
"""A fast and scalable high-order solver for computational fluid
dynamics"""
homepage = "https://nek5000.mcs.anl.gov/"
url = "https://github.com/Nek5000/Nek5000"
tags = ['cfd', 'flow', 'hpc', 'solver', 'navier-stokes',
'spectral-elements', 'fluid']
version('17.0.0-beta2', git='https://github.com/Nek5000/Nek5000.git',
commit='b95f46c59f017fff2fc19b66aa65a881085a7572')
version('develop', git='https://github.com/Nek5000/Nek5000.git',
branch='master')
# MPI, Profiling and Visit variants
variant('mpi', default=True, description='Build with MPI.')
variant('profiling', default=True, description='Build with profiling data.')
variant('visit', default=False, description='Build with Visit.')
# Variant for MAXNEL, we need to read this from user
variant(
'MAXNEL',
default=150000,
description='Maximum number of elements for Nek5000 tools.',
values=is_integral
)
# Variants for Nek tools
variant('genbox', default=True, description='Build genbox tool.')
variant('int_tp', default=True, description='Build int_tp tool.')
variant('n2to3', default=True, description='Build n2to3 tool.')
variant('postnek', default=True, description='Build postnek tool.')
variant('reatore2', default=True, description='Build reatore2 tool.')
variant('genmap', default=True, description='Build genmap tool.')
variant('nekmerge', default=True, description='Build nekmerge tool.')
variant('prenek', default=True, description='Build prenek tool.')
# Dependencies
depends_on('mpi', when="+mpi")
depends_on('visit', when="+visit")
@run_before('install')
def fortran_check(self):
if not self.compiler.fc:
msg = 'Cannot build Nek5000 without a Fortran compiler.'
raise RuntimeError(msg)
def install(self, spec, prefix):
toolsDir = 'tools'
binDir = 'bin'
F77 = self.compiler.fc
CC = self.compiler.cc
# Build the tools, maketools copy them to Nek5000/bin by default.
# We will then install Nek5000/bin under prefix after that.
with working_dir(toolsDir):
# Update the maketools script to use correct compilers
if self.version == Version('17.0.0-beta2'): # Old release
filter_file(r'^F77\s*=.*', 'F77=\"' + F77 + '\"', 'maketools')
else:
filter_file(r'^FC\s*=.*', 'FC=\"' + F77 + '\"', 'maketools')
filter_file(r'^CC\s*=.*', 'CC=\"' + CC + '\"', 'maketools')
maxnel = self.spec.variants['MAXNEL'].value
filter_file(r'^#MAXNEL\s*=.*', 'MAXNEL=' + maxnel, 'maketools')
makeTools = Executable('./maketools')
# Build the tools
if '+genbox' in spec:
makeTools('genbox')
if '+int_tp' in spec and self.version == Version('17.0.0-beta2'):
makeTools('int_tp')
if '+n2to3' in spec:
makeTools('n2to3')
if '+postnek' in spec:
makeTools('postnek')
if '+reatore2' in spec:
makeTools('reatore2')
if '+genmap' in spec:
makeTools('genmap')
if '+nekmerge' in spec:
makeTools('nekmerge')
if '+prenek' in spec:
makeTools('prenek')
with working_dir(binDir):
if '+mpi' in spec:
F77 = spec['mpi'].mpif77
CC = spec['mpi'].mpicc
else:
filter_file(r'^#MPI=0', 'MPI=0', 'makenek')
if '+profiling' not in spec:
filter_file(r'^#PROFILING=0', 'PROFILING=0', 'makenek')
if '+visit' in spec:
filter_file(r'^#VISIT=1', 'VISIT=1', 'makenek')
filter_file(r'^#VISIT_INSTALL=.*', 'VISIT_INSTALL=\"' +
spec['visit'].prefix.bin + '\"', 'makenek')
# Update the makenek to use correct compilers and
# Nek5000 source.
filter_file(r'^F77\s*=.*', 'F77=\"' + F77 + '\"', 'makenek')
filter_file(r'^CC\s*=.*', 'CC=\"' + CC + '\"', 'makenek')
filter_file(r'SOURCE_ROOT\s*=\"\$H.*', 'SOURCE_ROOT=\"' +
prefix.bin.Nek5000 + '\"', 'makenek')
# Install Nek5000/bin in prefix/bin
install_tree(binDir, prefix.bin)
# Copy Nek5000 source to prefix/bin
install_tree('../Nek5000', prefix.bin.Nek5000)
|