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
|
# Copyright 2013-2018 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)
from spack import *
import glob
import tempfile
class Wps(Package):
"""The Weather Research and Forecasting Pre-Processing System (WPS)
"""
homepage = "https://www.mmm.ucar.edu/weather-research-and-forecasting-model"
url = "https://github.com/wrf-model/WPS/archive/v4.2.tar.gz"
maintainers = ['MichaelLaufer']
version('4.2', sha256='3e175d033355d3e7638be75bc7c0bc0de6da299ebd175a9bbc1b7a121acd0168')
# Serial variant recommended in WRF/WPS docs
variant('build_type', default='serial',
values=('serial', 'serial_NO_GRIB2', 'dmpar', 'dmpar_NO_GRIB2'))
# These patches deal with netcdf & netcdf-fortran being two diff things
patch('patches/4.2/arch.Config.pl.patch', when='@4.2')
patch('patches/4.2/arch.configure.defaults.patch', when='@4.2')
patch('patches/4.2/configure.patch', when='@4.2')
patch('patches/4.2/preamble.patch', when='@4.2')
# According to:
# http://www2.mmm.ucar.edu/wrf/users/docs/user_guide_v4/v4.0/users_guide_chap2.html#_Required_Compilers_and_1
# Section: "Required/Optional Libraries to Download"
depends_on('wrf')
depends_on('netcdf-c')
depends_on('netcdf-fortran')
# build script use csh
depends_on('tcsh', type=('build'))
# this fixes that for csh install scripts
depends_on('time', type=('build'))
depends_on('m4', type='build')
depends_on('libtool', type='build')
depends_on('jasper')
phases = ['configure', 'build', 'install']
def setup_build_environment(self, env):
env.set('WRF_DIR', self.spec['wrf'].prefix)
env.set('NETCDF', self.spec['netcdf-c'].prefix)
# This gets used via the applied patch files
env.set('NETCDFF', self.spec['netcdf-fortran'].prefix)
env.set('JASPERINC', self.spec['jasper'].prefix.include)
env.set('JASPERLIB', self.spec['jasper'].prefix.lib)
if self.spec.satisfies('%gcc@10:'):
args = '-w -O2 -fallow-argument-mismatch -fallow-invalid-boz'
env.set('FCFLAGS', args)
env.set('FFLAGS', args)
def patch(self):
# Let's not assume csh is intalled in bin
files = glob.glob('*.csh')
filter_file('^#!/bin/csh -f', '#!/usr/bin/env csh', *files)
filter_file('^#!/bin/csh', '#!/usr/bin/env csh', *files)
def configure(self, spec, prefix):
build_opts = {"gcc": {"serial": '1',
"serial_NO_GRIB2": '2',
"dmpar": '3',
"dmpar_NO_GRIB2": '4'},
"intel": {"serial": '17',
"serial_NO_GRIB2": '18',
"dmpar": '19',
"dmpar_NO_GRIB2": '20'},
"pgi": {"serial": '5',
"serial_NO_GRIB2": '6',
"dmpar": '7',
"dmpar_NO_GRIB2": '8'},
}
try:
compiler_opts = build_opts[self.spec.compiler.name]
except KeyError:
raise InstallError("Compiler not recognized nor supported.")
# Spack already makes sure that the variant value is part of the set.
build_type = compiler_opts[spec.variants['build_type'].value]
with tempfile.TemporaryFile(mode='w') as fp:
fp.write(build_type + '\n')
fp.seek(0)
Executable('./configure')(input=fp)
def build(self, spec, prefix):
csh = which('csh')
csh('./compile')
def install(self, spec, prefix):
# Copy all of WPS staging dir to install dir
install_tree('.', prefix)
|