# Copyright 2013-2019 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 glob import os from spack import * class Ioapi(MakefilePackage): """Models-3/EDSS Input/Output Applications Programming Interface.""" homepage = "https://www.cmascenter.org/ioapi/" url = "https://www.cmascenter.org/ioapi/download/ioapi-3.2.tar.gz" git = "https://github.com/cjcoats/ioapi-3.2" version('3.2', sha256='4858415e265d017b45d8b2d661286d8db8f6e70a5736f7a0d06ca275fab84c47') version('3.2-large', commit='3490a48998ea4fec7946f254e1aaf8bb7790f1e0') depends_on('mpi') depends_on('netcdf@4:') depends_on('netcdf-fortran@4:') depends_on('sed', type='build') def edit(self, spec, prefix): # No default Makefile bundled; edit the template. os.symlink('Makefile.template', 'Makefile') # The makefile uses stubborn assignments of = instead of ?= so # edit the makefile instead of using environmental variables. makefile = FileFilter('Makefile') if spec.satisfies('%gcc'): bin = 'Linux2_x86_64gfort_medium' elif spec.satisfies('%intel'): bin = 'Linux2_x86_64ifort_medium' elif spec.satisfies('%pg'): bin = 'Linux2_x86_64pg_medium' makefile.filter('^BIN.*', 'BIN = ' + bin) makefile.filter('^BASEDIR.*', 'BASEDIR = ' + self.build_directory) makefile.filter('^INSTALL.*', 'INSTALL = ' + prefix) makefile.filter('^BININST.*', 'BININST = ' + prefix.bin) makefile.filter('^LIBINST.*', 'LIBINST = ' + prefix.lib) # Compile m3tools with PIC, otherwise linking airs2m3 fails. flag = '-fPIE' env['LFLAGS'] = flag # Compile ioapi with PIC, otherwise linking airs2m3 fails. makeinclude = FileFilter(os.path.join('ioapi', 'Makeinclude.' + bin)) makeinclude.filter('^(MFLAGS.*=)(.*)', r'\1 ' + flag + r'\2') makeinclude.filter('^(FOPTFLAGS.*)', r'\1 ' + flag) def install(self, spec, prefix): make('install') # Install the header files. mkdirp(prefix.include.fixed132) headers = glob.glob('ioapi/*.EXT') for header in headers: install(header, prefix.include) # Install the header files for CMAQ and SMOKE in the # non-standard -ffixed-line-length-132 format. headers_fixed132 = glob.glob('ioapi/fixed_src/*.EXT') for header in headers_fixed132: install(header, prefix.include.fixed132)