Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added WPS on top of WRF, and updated both to v4.2 #5

Open
wants to merge 1 commit into
base: packages/wrf
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions var/spack/repos/builtin/packages/wps/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# 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
from os.path import dirname,join
import multiprocessing as mp

class Wps(AutotoolsPackage):
"""The Weather Research and Forecasting Pre-Processing System (WPS)
"""

homepage = "https://www.mmm.ucar.edu/weather-research-and-forecasting-model"
#url = "https://www2.mmm.ucar.edu/wrf/src/WPSV4.0.TAR.gz"
url = "https://github.com/wrf-model/WPS/archive/v4.2.tar.gz"

version('4.2', sha256='3e175d033355d3e7638be75bc7c0bc0de6da299ebd175a9bbc1b7a121acd0168')

variant('build_type', default='dmpar',
values=('serial', 'serial_NO_GRIB2', 'dmpar', 'dmpar_NO_GRIB2'))

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')


depends_on('mpi')
depends_on('wrf')
# 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"
# parallel netcdf should not be used
depends_on('netcdf-c~parallel-netcdf')
depends_on('netcdf-fortran')
# not sure if +fortran is required, but seems like a good idea
depends_on('hdf5+fortran+hl')
# build script use csh
depends_on('tcsh', type=('build'))
# time is not installed on all systems b/c bash provides it
# this fixes that for csh install scripts
depends_on('time', type=('build'))

depends_on('autoconf', type='build')
depends_on('automake', type='build')
depends_on('m4', type='build')
depends_on('libtool', type='build')
depends_on('jasper')

def setup_environment(self, spack_env, run_env):
spack_env.set('NETCDF', self.spec['netcdf-c'].prefix)
# This gets used via the applied patch files
spack_env.set('NETCDFF', self.spec['netcdf-fortran'].prefix)
spack_env.set('JASPERINC', self.spec['jasper'].prefix.include)
spack_env.set('JASPERLIB', self.spec['jasper'].prefix.lib)

# This is a hack - we need to use WRF staging ("spack install -- wrf")
spack_env.set('WRF_DIR', join(glob.glob(join(dirname(dirname(self.stage.source_path)), "spack-stage-wrf-%s-*" % str(self.version)))[0], "spack-src"))

if self.spec.satisfies('%gcc@10:'):
spack_env.set('FCFLAGS', '-w -O2 -fallow-argument-mismatch -fallow-invalid-boz')
spack_env.set('FFLAGS', '-w -O2 -fallow-argument-mismatch -fallow-invalid-boz')

spack_env.prepend_path('PATH', dirname(self.compiler.fc))

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):
mkdir(prefix.bin)
install('./geogrid/src/geogrid.exe', prefix.bin)
install('./metgrid/src/metgrid.exe', prefix.bin)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/arch/Config.pl b/arch/Config.pl
index 89f86bf..e08bc75 100644
--- a/arch/Config.pl
+++ b/arch/Config.pl
@@ -9,6 +9,7 @@
$sw_perl_path = perl;
$sw_wrf_path = "<SET ME>";
$sw_netcdf_path = "";
+$sw_netcdff_path = "";
$sw_netcdff_lib = "";
$sw_phdf5_path = "";
$sw_jasperlib_path = "";
@@ -40,7 +41,11 @@ while(substr( $ARGV[0], 0, 1 ) eq "-")
}
if(substr( $ARGV[0], 1, 8 ) eq "netcdff=")
{
- $sw_netcdff_lib = substr( $ARGV[0], 9);
+ $sw_netcdff_path = substr( $ARGV[0], 9);
+ }
+ if(substr( $ARGV[0], 1, 11 ) eq "netcdfflib=")
+ {
+ $sw_netcdff_lib = substr( $ARGV[0], 12);
}
if(substr( $ARGV[0], 1, 6 ) eq "phdf5=")
{
@@ -167,6 +172,7 @@ while(<CONFIGURE_DEFAULTS>)
{
$_ =~ s/CONFIGURE_PERL_PATH/$sw_perl_path/g;
$_ =~ s/CONFIGURE_NETCDF_PATH/$sw_netcdf_path/g;
+ $_ =~ s/CONFIGURE_NETCDFF_PATH/$sw_netcdff_path/g;
$_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g;
$_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g;
$_ =~ s/CONFIGURE_COMP_L/$sw_compL/g;
Loading